package controller;

import java.io.BufferedWriter;
import java.io.IOException;
//import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;

import pojo.Protocol;
import socket.ClientSocket;
import util.ProtocolJSONConverter;

public class LoginController {
	public void control(String from,String pwd) throws IOException{
		OutputStream out = ClientSocket.getInstance().getOutputStream();
		Protocol protocol = new Protocol(Protocol.LOGIN, pwd, from, null, null);
		
//		ObjectOutputStream objOut = new ObjectOutputStream(out);
//		objOut.writeObject(protocol);
		
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
		writer.write(ProtocolJSONConverter.toJSON(protocol) + "\r\n");
		writer.flush();
		
//		out.close();
//		objOut.close();
	}
}
